#!/usr/bin/env bash
set -euo pipefail

export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"

script() {
   echo "#!/usr/bin/env bash"
   echo "${SCRIPT_DIR}/navi" '"$@"'
}

folder="${1:-/usr/local/bin}"
bin="${folder}/navi"

script > "$bin"
chmod +x "$bin"